---
title: 'getAllCookies | Cypress Documentation'
description: Get all browser cookies in Cypress.
sidebar_label: getAllCookies
---

<ProductHeading product="app" />

# getAllCookies

Get all browser cookies.

## Syntax

```javascript
cy.getAllCookies()
cy.getAllCookies(options)
```

### Usage

<Icon name="check-circle" color="green" /> **Correct Usage**

```javascript
cy.getAllCookies() // Get all cookies
```

### Arguments

<Icon name="angle-right" /> **options _(Object)_**

Pass in an options object to change the default behavior of
`cy.getAllCookies()`.

| Option    | Default                                                     | Description                                                                         |
| --------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `log`     | `true`                                                      | Displays the command in the [Command log](/app/core-concepts/open-mode#Command-Log) |
| `timeout` | [`responseTimeout`](/app/references/configuration#Timeouts) | Time to wait for `cy.getAllCookies()` to resolve before [timing out](#Timeouts)     |

<HeaderYields />

`cy.getAllCookies()` yields an array of cookie objects. Each cookie object has
the following properties:

- `domain`: _(String)_
- `expiry`: _(Number)_ _(if specified)_
- `hostOnly`: _(Boolean)_ _(if specified)_
- `httpOnly`: _(Boolean)_
- `name`: _(String)_
- `path`: _(String)_
- `sameSite`: _(String)_ _(if specified)_
- `secure`: _(Boolean)_
- `value`: _(String)_

`cy.getAllCookies()` is not a query. It will not update the returned list if
further cookies are added after it initially executes.

## Examples

### Get Cookies

#### Get cookies after logging in

In this example, we log in through an identity provider which sets a cookie and
redirects back to our site, which sets a session cookie.

```javascript
cy.contains('Log in').click()
cy.origin('https://example.cypress.io', () => {
  cy.get('[type=password]').type('*****')
  cy.contains('Log in').click()
})
cy.url().should('include', 'profile')
cy.getAllCookies()
  .should('have.length', 2)
  .then((cookies) => {
    expect(cookies[0]).to.have.property('name', 'identity_session_id')
    expect(cookies[1]).to.have.property('name', 'session_id')
  })
```

## Rules

<HeaderRequirements />

- `cy.getAllCookies()` requires being chained off of `cy`.

<HeaderAssertions />

- `cy.getAllCookies()` will only run assertions you have chained once, and will
  not [retry](/app/core-concepts/retry-ability).

<HeaderTimeouts />

- `cy.getAllCookies()` should never time out.

:::caution

Because `cy.getAllCookies()` is asynchronous it is technically possible for
there to be a timeout while talking to the internal Cypress automation APIs. But
for practical purposes it should never happen.

:::

## See also

- [`cy.clearAllCookies()`](/api/commands/clearallcookies)
- [`cy.clearCookie()`](/api/commands/clearcookie)
- [`cy.clearCookies()`](/api/commands/clearcookies)
- [`cy.getCookie()`](/api/commands/getcookie)
- [`cy.setCookie()`](/api/commands/setcookie)
- [`Cypress.Cookies.debug()`](/api/cypress-api/cookies)
